/*
 * TTracer.h
 *
 *  Created on: 2010-12-15
 *      Author: Xairy
 */

#ifndef TTRACER_H_
#define TTRACER_H_

#include <e32cmn.h>
class CClient;

#define TRACER(func) TTracer function_tracer( _S(func));

/*
 * 不建议使用多线程，会带来效率的严重的损失
 *  注意：该段代码只是说明了多线程崩溃的可支持性，当并没有经过严密的测试
 */
#ifdef USE_MULTITHREAD_LLLLL
#define KMaxThreadNum 4
struct TThreadClient
{
    CClient* iClient;
    TUint64 iThreadId;
    
    TThreadClient()  
        :iClient(0), iThreadId(0){}
    
    ~TThreadClient();

};
#endif


class TTracer
{    
public:
    static void Init(TInt aStackSize = 4096);
    static void Destory();
    
    TTracer(const TText* aFunc);
    ~TTracer();

#ifdef USE_MULTITHREAD_LLLLL
    void MainThreadExit();
#endif

    static TBool iIsOn;
private:
#ifdef USE_MULTITHREAD_LLLLL
    static TThreadClient iThreadTracer[KMaxThreadNum];
    static TInt iThreadNum;
    static TThreadClient* Find(TUint64 aThreadId);
    
    TThreadClient* iThreadClient;
#else
    static CClient* iTracer;
    static TFullName iTracerName;
#endif
   
    TPtrC iFunc;
};

#endif /* TTRACER_H_ */
